<?php
namespace App\Http\Controllers\Member;

use App\Models\Comments;
use App\Models\CompanyComment;
use App\Models\EmployComments;
use App\Models\Courses;
use App\Models\CourseScore;


class CommentController extends MemberController
{
    
     /*
      * @see \App\Http\Controllers\Member\MemberController::__construct()
      */
     public function __construct() {
         parent::__construct();
     }

    /**
     * 就业指南评论
     */
    public function index()
    {
        $comments = EmployComments::where(array('user_id'=>$this->uid,'to_comment_id'=>0))->paginate(20);
        return view('member.comment.employ')->with('comments',$comments);
    }

    /**
     * 充电加油评论
     */
    public function teaches()
    {
        $comments = Comments::whereIn('app_table', array('teaches', 'tcompany','tcourse'))->where(array('user_id'=>$this->uid,'to_comment_id'=>0))->paginate(20);
        return view('member.comment.teaches')->with('comments',$comments);
    }

    /**
     * 充电加油 课程评论
     */
    public function course()
    {
        $comments = CourseScore::where(array('u_id'=>$this->uid,'to_comment_id'=>0))->paginate(20);
        foreach ($comments as $key => $val) {
            $comments[$key]['cname'] = Courses::find($val->c_id)['name'];
        }
        return view('member.comment.course')->with('comments',$comments);
    }
    
    /**
     * 公司 职位评论
     */
    public function company()
    {
        $comments = CompanyComment::where(array('user_id'=>$this->uid,'to_comment_id'=>0))->paginate(20);
        return view('member.comment.companys')->with('comments',$comments);
    }

}